package gy.rpc.api.dto;

import java.io.Serializable;

/**
 * @author G_Y
 * @date 2018年4月22日
 * @说明: 封装rpc调用结果_数据传输对象
 */
public class ResultDTO implements Serializable {

	/**
	 * 支持序列化
	 */
	private static final long serialVersionUID = 9199130070054552125L;

	public ResultDTO() {}
	
	public ResultDTO(Exception exception, String msg, Object result) {
		this.exception = exception;
		this.msg = msg;
		this.result = result;
	}
	
	public ResultDTO(String msg, Object result) {
		this.msg = msg;
		this.result = result;
	}
	
	/**
	 * rpc服务端处理异常封装
	 */
	private Exception exception;
	
	/**
	 * 处理结果说明
	 */
	private String msg;
	
	/**
	 * Service调用结果数据
	 * 结果数据_对象类型需要可序列化
	 */
	private Object result;
	
	/**
	 * rpc调用唯一区分 
	 * 与请求的 rpcId 保持一致
	 */
	private String rpcId;

	/**
	 * @return the rpcId
	 */
	public String getRpcId() {
		return rpcId;
	}

	/**
	 * @param rpcId the rpcId to set
	 */
	public ResultDTO setRpcId(String rpcId) {
		this.rpcId = rpcId;
		return this;
	}

	/**
	 * @return the exception
	 */
	public Exception getException() {
		return exception;
	}

	/**
	 * @param exception the exception to set
	 */
	public ResultDTO setException(Exception exception) {
		this.exception = exception;
		return this;
	}

	/**
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * @param msg the msg to set
	 */
	public ResultDTO setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	/**
	 * @return the result
	 */
	public Object getResult() {
		return result;
	}

	/**
	 * @param result the result to set
	 */
	public ResultDTO setResult(Object result) {
		this.result = result;
		return this;
	}

	@Override
	public String toString() {
		return this.result.toString();
	}
	
}
